package com.item.controller;


import com.item.domain.TbUserLike;
import com.item.po.TbUserLikePo;
import com.item.service.TbUserLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TbUserLikeController {

    @Autowired
    TbUserLikeService tbUserLikeService;

    @PostMapping(value = "/tbUserLike/{limit}/{page}")
    public List<TbUserLike> TbUserLike(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) TbUserLikePo tbUserLike) {
        List<TbUserLike> tbUserLikes = tbUserLikeService.findAll(limit, page, tbUserLike);


        return tbUserLikes;
    }

    @PostMapping(value = "/tbUserLike/add")
    public Integer TbUserLikeAdd(@RequestBody TbUserLike tbUserLike) {
        tbUserLike.setCreateTime(System.currentTimeMillis() + "");
        int i = tbUserLikeService.add(tbUserLike);
        return i;
    }

    @PutMapping(value = "/tbUserLike/update")
    public Integer tbUserLikeUpdate(@RequestBody TbUserLike tbUserLike) {

        int i = tbUserLikeService.update(tbUserLike);
        return i;
    }

    @DeleteMapping(value = "/tbUserLike/{id}")
    public Integer tbUserLikeDelete(@PathVariable(value = "id") int id) {

        int i = tbUserLikeService.delete(id);
        return i;
    }

}
